<?php

require_once('Doctrine.php');

class FP_Application_Subsystem_Database implements FP_Application_Subsystem_Interface {

    protected $_config = null;

    public function init($pConfig=null){

	$this->_config = $pConfig;

	$autoloader = Zend_Loader_Autoloader::getInstance();
	$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
	$autoloader->pushAutoloader(array('Doctrine', 'modelsAutoload'));

	$dsn = "{$this->_config->type}://{$this->_config->user}:{$this->_config->password}@{$this->_config->host}/{$this->_config->database}";

	try {
	    Doctrine_Manager::connection($dsn);
	} catch (Exception $x){
	    throw new FP_Application_Exception($x->getMessage(), DATABASE_ERROR_EXCEPTION);
	}

    }


}

?>